#ifndef GAME_H
#define GAME_H
#include<QApplication>
#include<QWidget>
#include<QPaintEvent>
#include<QTime>
#include<QDebug>
#include<QPainter>
#include<QMouseEvent>
#include<QPainterPath>
#include<QPen>
#include<QColor>
#include<QBrush>
#include<QMessageBox>
#include<QRadioButton>
#include<QButtonGroup>
#include<qpalette.h>
#include<QtDebug>
#include<QPushButton>
#include<QLabel>
#include<QMainWindow>


using namespace std;

#define BOARD_COL  15        // 棋盘列数
#define BOARD_ROW  15        // 棋盘行数

class Game : public QWidget
{
    Q_OBJECT

public:
    Game(QWidget *parent = nullptr);

protected:
    void paintEvent(QPaintEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;
    void mousePressEvent(QMouseEvent *event) override;

private slots:
    void SelectRadio();
    void oper();
    void back();

private:
    void update_chessboard(int x, int y);
    void PERSON_time(QMouseEvent *event);
    void AI_time();
    int getPointAt(QPoint p, int dir, int offset);
    int isWin(QPoint p);
    void Is_Someone_Win(int x, int y);

    QVector<QPoint> GetAllDropPiecePos();       // 返回棋盘上所有NO_PIECE位置
    int GetPieceScore(int x,int y,int player);  // 返回该位置相对于player的分数
    int GetPosValue(int x,int y);               // 返回该位置的分数，越靠近中间分数越高
    int GetChessType(int x,int y,int direction,int pieceColor);     // 返回该位置direction方向上的棋形
    int GetLinePieceNum(int x,int y,int direction,int pieceColor,int &pieceEnd);    //获取该位置该方向上pieceColor颜色的连续棋子数，pieceEnd为结束位置棋子
    bool IsBeyond(int x,int y);

    int board[15][15];
    int game_type;
    int player;
    int flag;
    int lock;
    int currentX, currentY;
    int moveX, moveY;
    QList<QPoint> sta;
    // std::stack<QPoint> sta;
    QString winner;
    QButtonGroup *SelectModeGroup;
    QPushButton *button;

    static const QPoint m_dir[8];

};

#endif // GAME_H
